﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Helpers;

namespace Api
{
    public class ResultHand
    {
        /// <summary>
        /// 数据返回通用方法
        /// </summary>
        /// <param name="obj">返回数据</param>
        /// <param name="ReasonPhrase">服务器返回状态短语</param>
        /// <param name="code">服务器返回状态</param>
        /// <returns></returns>
        public static HttpResponseMessage OnResult(object obj, string ReasonPhrase = "通讯成功", HttpStatusCode httpStatusCode = HttpStatusCode.OK)
        {
           // LogUtility.LogHelper.Warn( obj.ToString());

            return new HttpResponseMessage(httpStatusCode) { Content = new StringContent(Json.Encode(obj)), ReasonPhrase = ReasonPhrase };
        }
    }
}